package com.sam.im.heiqun.widgets.imagepicker;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 图片实体
 * Created by Nereo on 2015/4/7.
 */
public class MediaBean implements Parcelable {

    public static final int TYPE_IMAGE = 0;
    public static final int TYPE_VIDEO = 1;

    public String path;
    public String name;
    public long time;
    public int type;
    public long videoDuration;

    public MediaBean(String path, String name, long time, int type) {
        this.path = path;
        this.name = name;
        this.time = time;
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        try {
            MediaBean other = (MediaBean) o;
            return this.path.equalsIgnoreCase(other.path);
        }catch (ClassCastException e){
            e.printStackTrace();
        }
        return super.equals(o);
    }


    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public long getVideoDuration() {
        return videoDuration;
    }

    public void setVideoDuration(long videoDuration) {
        this.videoDuration = videoDuration;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.path);
        dest.writeString(this.name);
        dest.writeLong(this.time);
        dest.writeInt(this.type);
        dest.writeLong(this.videoDuration);
    }

    protected MediaBean(Parcel in) {
        this.path = in.readString();
        this.name = in.readString();
        this.time = in.readLong();
        this.type = in.readInt();
        this.videoDuration = in.readLong();
    }

    public static final Creator<MediaBean> CREATOR = new Creator<MediaBean>() {
        @Override
        public MediaBean createFromParcel(Parcel source) {
            return new MediaBean(source);
        }

        @Override
        public MediaBean[] newArray(int size) {
            return new MediaBean[size];
        }
    };
}
